PropertyConfig = function() {
	return {
		
		init : function() {
			$('#industryDataGrid').datagrid({
				url				: basePath + '/pc/industry/list.htm',
				fit				: true,
				fitColumns		: true,
				striped			: true,
				rownumbers		: true,
				autoRowHeight	: true,
				singleSelect    : true,
				nowrap			: true,
				pagination		: true,
				pageSize        : 20,
				pageList        : [10, 20, 30, 40, 50],
				method 			: 'POST',
				columns			: [[
				    {field : 'industryId',          title : '行业ID',       width : 100,   hidden : true},
				    {field : 'channelName',         title : '频道名称',     width : 100},
				    {field : 'industryName',        title : '行业名称',     width : 100}
				]],
				onClickRow      : function(rowIndex, rowData) {
		        	var industryId = rowData.industryId;
		        	$('#propertyDataGrid').datagrid({ 
		        		url         : '/pc/property/list.htm', 
		                queryParams : {	industryId : industryId }
		        	}).load();
		        }
			});
			
			$('#propertyDataGrid').datagrid({
				fit				: true,
				fitColumns		: true,
				striped			: true,
				rownumbers		: true,
				autoRowHeight	: true,
				nowrap			: true,
				pagination		: true,
				pageSize        : 20,
				pageList        : [10, 20, 30, 40, 50],
				method 			: 'POST',
				columns			: [[
				    {field : 'resourcePropertyId',          title : '资源属性ID',       width : 100,   hidden : true},
				    {field : 'resourcePropertyName',        title : '资源属性名称',     width : 100},
				    {field : 'resourcePropertyEnname',      title : '资源属性代码',     width : 100},
				    {field : 'resourcePropertyFlag',        title : '是否必填',         width : 100, 
				    	formatter : function(value, rowData, index) {
				    		var result = "";
				    		if(value == '0') {
				    			result = "<strong><font color='red'>是</font></strong>";
				    		} else {
				    			result = "否";
				    		}
				    		return result;
				    	}
				    }
				]],
				toolbar     : [{
					text    : '添加',
					iconCls : 'add',
					handler : function() {
						var record = $("#industryDataGrid").datagrid("getSelected");
						if(record) {
							Ict.warn("该功能暂未开放，请确认!");
							return;
							Ict.openWin("添加资源属性", 460, 290, "/pc/property/add.htm?industryId=" + record.industryId);
						} else {
							Ict.warn("请选择行业!");
						}
					}
				}, {
					text    : '修改',
					iconCls : 'edit',
					handler : function() {
						var record = $("#industryDataGrid").datagrid("getSelected");
						if(record) {
							var rows = $("#propertyDataGrid").datagrid("getSelections");
							if(rows.length == 1) {
								var propertyId = rows[0].resourcePropertyId;
								Ict.openWin("编辑资源属性", 460, 290, "/pc/property/edit.htm?industryId=" + record.industryId + "&propertyId=" + propertyId);
							} else {
								Ict.warn("请选择一条记录!");
							}
						} else {
							Ict.warn("请选择行业!");
						}
					}
				}, {
					text    : '删除',
					iconCls : 'remove',
					handler : function() {
						var record = $("#industryDataGrid").datagrid("getSelected");
						if(record) {
							Ict.warn("该功能暂未开放，请确认!");
							return;
							var rows = $("#propertyDataGrid").datagrid("getSelections");
							if(rows.length == 0) {
								Ict.warn("没有选中记录!");
							} else {
								var idArray = "";
								for(var i = 0; i < rows.length; i++) {
									idArray += rows[i].resourcePropertyId + ",";
								}
								idArray = idArray.substring(0, idArray.length - 1);
								Ict.confirm("确定要删除所选记录?", function(btn) {
									if(btn) {
										$.post("/pc/property/remove.htm", {'propertyIds' : idArray}, function(data) {
			    							if(data == "SUCCESS") {
			    								Ict.info("删除成功!", function() {
			    									$("#propertyDataGrid").datagrid("reload");
			    					    		});
			    							} else {
			    								Ict.error("删除失败!");
			    							}
			    						});
									}
								});
							}
						} else {
							Ict.warn("请选择行业!");
						}
					}
				}, {
					text    : '刷新',
					iconCls : 'reload',
					handler : function() {
						$('#propertyDataGrid').datagrid('reload');
					}
				}]
			});
		}
	};
}();

$(function(){
	PropertyConfig.init();
});